

# include "banner.h"

# include <malloc.h>
# include <stdio.h>

# include "node_banner.h"

typedef int zint_32;

pNode InitNode(zint_32 value)
{
	pNode pNodeTest;
	pNodeTest = (pNode)malloc(sizeof(Node));
	pNodeTest->Date = value;
	pNodeTest->pNext = NULL;
	pNodeTest->Frequency = 1;
	return pNodeTest;
}


State_banner ChangeNode(pNode pNodeTes, zint_32 Value)
{
	if (pNodeTes != NULL)
	{
		pNodeTes->Date = Value;
	}
	return 0;
}

State_banner ShowNode(pNode pNodeTes)
{
	if (pNodeTes != NULL)
	{
		printf("%d \t", pNodeTes->Date);
		
		if (pNodeTes->pNext != NULL)
		{
			ShowNode(pNodeTes->pNext);
		}
	}
	
	return 0;
}

State_banner ShowAllNode(pNode pNodeTes)
{
	if (pNodeTes != NULL)
	{
		printf("AllNode: Frequency is %d | It's \t", pNodeTes->Frequency);
		ShowNode(pNodeTes);
		printf("\n");
	}
}

State_banner AddNode(pNode pFirstNode, pNode pSoundNode)
{
	if (pFirstNode->pNext == NULL)
	{
		pFirstNode->pNext = (pNode)malloc(sizeof(Node));
		pFirstNode->pNext->Date = pSoundNode->Date;
		pFirstNode->pNext->pNext = pSoundNode->pNext;
	}
	else
	{
		AddNode(pFirstNode->pNext, pSoundNode);
	}
	return 0;
}

State_banner DeleteNode(Node **pNodeTest)
{
	if (*pNodeTest != NULL)
	{
		DeleteNode(&(*pNodeTest)->pNext);
		free(*pNodeTest);
		*pNodeTest = NULL;
	}
	return 0;
}
